package com.ruoyi.feedback.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.feedback.domain.TbDateFeedback;
import com.ruoyi.feedback.service.ITbDateFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.user.domain.TbUser;
import com.ruoyi.user.mapper.TbUserMapper;
import com.ruoyi.arrangement.domain.TbDateArrangement;
import com.ruoyi.arrangement.mapper.TbDateArrangementMapper;

/**
 * 约会反馈Controller
 * 
 * @author ruoyi
 * @date 2025-08-01
 */
@RestController
@RequestMapping("/feedback/feedback")
public class TbDateFeedbackController extends BaseController
{
    @Autowired
    private ITbDateFeedbackService tbDateFeedbackService;

    @Autowired
    private TbUserMapper tbUserMapper;

    @Autowired
    private TbDateArrangementMapper tbDateArrangementMapper;

    /**
     * 查询约会反馈列表
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbDateFeedback tbDateFeedback)
    {
        startPage();
        List<TbDateFeedback> list = tbDateFeedbackService.selectTbDateFeedbackList(tbDateFeedback);
        return getDataTable(list);
    }

    /**
     * 导出约会反馈列表
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:export')")
    @Log(title = "约会反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbDateFeedback tbDateFeedback)
    {
        List<TbDateFeedback> list = tbDateFeedbackService.selectTbDateFeedbackList(tbDateFeedback);
        ExcelUtil<TbDateFeedback> util = new ExcelUtil<TbDateFeedback>(TbDateFeedback.class);
        util.exportExcel(response, list, "约会反馈数据");
    }





    /**
     * 删除约会反馈
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:remove')")
    @Log(title = "约会反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedbackIds}")
    public AjaxResult remove(@PathVariable Long[] feedbackIds)
    {
        return toAjax(tbDateFeedbackService.deleteTbDateFeedbackByFeedbackIds(feedbackIds));
    }

    /**
     * 根据用户ID获取用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:query')")
    @GetMapping("/user/{userId}")
    public AjaxResult getUserInfo(@PathVariable("userId") Long userId)
    {
        TbUser user = tbUserMapper.selectTbUserByUserId(userId);
        return success(user);
    }

    /**
     * 根据约会安排ID获取约会安排详细信息
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:query')")
    @GetMapping("/arrangement/{arrangementId}")
    public AjaxResult getArrangementInfo(@PathVariable("arrangementId") Long arrangementId)
    {
        TbDateArrangement arrangement = tbDateArrangementMapper.selectTbDateArrangementByArrangementId(arrangementId);
        return success(arrangement);
    }
}
